package cn.fanrunqi.materiallogin.whUtil;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.view.View;

public class StatusBarUtil {

    /**
     * 获取状态栏高度
     *      获取状态栏高度 status_bar_height
     *      获取导航栏高度 navigation_bar_height
     */
    public static int getStatusBarHeight(Context context) {
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        return context.getResources().getDimensionPixelSize(resourceId);
    }

    public static int getActionBarHeight(Context context) {
        int resourceId = context.getResources().getIdentifier("action_bar_default_height", "dimen", "android");
        return context.getResources().getDimensionPixelSize(resourceId);
    }

    /**
     * 设置沉浸式明亮状态栏
     */
    public static void setStatusBarFullScreenLight(Activity activity) {
        // 设置状态栏文字颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
    }

    /**
     * 设置沉浸式一般状态栏
     */
    public static void setStatusBarFullScreenNormal(Activity activity) {
        // 设置状态栏文字颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_VISIBLE);
        }
    }

    /**
     * 设置明亮状态栏
     */
    public static void setStatusBarLight(Activity activity) {
        // 设置状态栏文字颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
    }

    /**
     * 设置明亮状态栏沉浸式
     */
    public static void setStatusBarLightFullScreen(Activity activity) {
        // 设置状态栏文字颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
    }

    /**
     * 设置一般状态栏
     */
    public static void setStatusBarNormal(Activity activity) {
        // 设置状态栏文字颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        }
    }

}
